import { useState } from 'react';
import Navigation from './Navigation';
import ProductList from './ProductList';
import RedeemCode from './RedeemCode';
import ExchangeRecords from './ExchangeRecords';

function Dashboard() {
  const [currentPage, setCurrentPage] = useState('products');

  // 根据当前选择的页面渲染对应组件
  const renderCurrentPage = () => {
    switch (currentPage) {
      case 'products':
        return <ProductList />;
      case 'redeem':
        return <RedeemCode />;
      case 'exchange-records':
        return <ExchangeRecords />;
      default:
        return <ProductList />;
    }
  };

  return (
    <div className="min-h-screen bg-gray-100">
      <Navigation onNavigate={setCurrentPage} currentPage={currentPage} />
      <main className="max-w-7xl mx-auto py-6 sm:px-6 lg:px-8">
        {renderCurrentPage()}
      </main>
    </div>
  );
}

export default Dashboard;